Skip to content

feat: python native bindings#49

Merged
aepfli merged 24 commits into
mainfrom
feat/python
Dec 26, 2025
Merged

feat: python native bindings#49
aepfli merged 24 commits into
mainfrom
feat/python

Conversation

@aepfli

@aepfli aepfli commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

Description

Related Issue

Closes #

Type of Change

  • feat: New feature (minor version bump)
  • fix: Bug fix (patch version bump)
  • docs: Documentation only changes
  • chore: Maintenance tasks, dependency updates
  • refactor: Code refactoring without functional changes
  • test: Adding or updating tests
  • ci: CI/CD changes
  • perf: Performance improvements
  • build: Build system changes
  • style: Code style/formatting changes

PR Title Format

IMPORTANT: Since we use squash and merge, your PR title will become the commit message. Please ensure your PR title follows the Conventional Commits format:

<type>(<optional-scope>): <description>

Examples:

  • feat(operators): add new string comparison operator
  • fix(wasm): correct memory allocation bug
  • docs: update API examples in README
  • chore(deps): update rust dependencies

For breaking changes, use ! after the type/scope or include BREAKING CHANGE: in the PR description:

  • feat(api)!: redesign evaluation API

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All tests pass (cargo test)
  • Code is formatted (cargo fmt)
  • Clippy checks pass (cargo clippy -- -D warnings)
  • WASM builds successfully (if applicable)

Breaking Changes

  • This PR includes breaking changes
  • Documentation has been updated to reflect breaking changes
  • Migration guide included (if needed)

Additional Notes

aepfli and others added 15 commits December 26, 2025 16:44
Add comprehensive Node.js/JavaScript WASM integration example showing all
9 required host functions with complete memory management. Update PyO3 issue
reference from placeholder to #47. Add napi-rs alternative section with
reference to issue #48.

Related: #47, #48
Remove evaluate_logic as a public method from both WASM exports and
Python bindings. The project is focused exclusively on flag evaluation
using the stateful update_state + evaluate pattern, not general-purpose
JSON Logic evaluation.

Changes:
- Remove evaluate_logic WASM export function from src/lib.rs
- Remove EvaluationResponse struct (no longer needed)
- Remove evaluate_logic from Python bindings (python/src/lib.rs)
- Update API Reference table in README.md
- Update all usage examples (Python, JavaScript, Rust) to use flag evaluation
- Remove Python examples that demonstrated evaluate_logic
- Remove test_operators.py (tested evaluate_logic)
- Update benchmarks to only test FlagEvaluator
- Remove PYTHON_TODO.md (all tasks completed)
- Clean up unused serde imports

This aligns the implementation with the flagd provider specification
and reduces API surface area.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
aepfli and others added 6 commits December 26, 2025 17:40
maturin develop requires a virtualenv to be active. Update the
test-python CI job to:
- Create a virtualenv before running maturin
- Activate the virtualenv in each step
- Install maturin and pytest into the virtualenv

This fixes the error: "Couldn't find a virtualenv or conda environment,
but you need one to use this command."

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Update PyO3 from 0.20 to 0.22 to resolve non-local impl definition
warnings and ensure compatibility with newer Rust compiler versions.

Changes:
- Update pyo3 and pythonize dependencies to 0.22
- Update method signatures to use Bound<'_, PyDict> instead of &PyDict
- Use .as_any() when calling depythonize (now requires &Bound<PyAny>)
- Use PyDict::new_bound() instead of PyDict::new()
- Update pymodule signature to use &Bound<PyModule>
- Convert pythonize result with .unbind() to match PyObject return type

This resolves the compiler warning:
"non-local impl definition, impl blocks should be written at the same
level as their item"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace manual venv creation and pip with uv, a fast Python package
installer and resolver written in Rust.

Benefits:
- Significantly faster package installation
- Built-in caching support
- Better dependency resolution
- More reliable in CI environments

Changes:
- Add astral-sh/setup-uv@v4 action
- Replace venv + pip with uv venv + uv pip install
- Enable uv caching for faster CI runs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add comprehensive uv documentation for Python bindings development
across all documentation files. uv is a fast Python package installer
and resolver written in Rust, providing significantly faster package
management than traditional pip.

Changes:
- README.md: Add Development section with uv quick start
- python/README.md: Add uv as recommended method with detailed instructions
- CLAUDE.md: Update Python bindings section with uv workflow
- Update outdated evaluate_logic references in examples

Benefits of using uv:
- 10-100x faster package installation
- Better dependency resolution
- Built-in virtualenv management
- Seamless drop-in replacement for pip

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add uv.lock file and update workflow to use uv's dependency groups
for reproducible, locked dependency installation in CI and local dev.

Changes:
- Add dependency-groups.dev in pyproject.toml (maturin, pytest)
- Generate uv.lock with locked dependency versions
- Update CI to use 'uv sync --group dev' instead of 'uv pip install'
- Update all documentation to use 'uv sync --group dev'

Benefits:
- Reproducible builds across environments
- Faster CI runs with locked dependencies
- Automatic venv creation with 'uv sync'
- No manual pip install or venv creation needed

The lock file ensures all developers and CI use identical dependency
versions, preventing "works on my machine" issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Update CI to use Python 3.9 as the test version. This ensures
compatibility with Python 3.9+ as specified in pyproject.toml
(requires-python = ">=3.8").

Python 3.9 is a good balance between:
- Modern features and performance
- Wide compatibility (still supported until Oct 2025)
- Common in enterprise environments

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
aepfli and others added 3 commits December 26, 2025 18:01
Explicitly target Python 3.9-3.13 to avoid compatibility issues with
Python 3.14, which is not yet supported by PyO3 0.22.

Changes:
- Update pyproject.toml: requires-python = ">=3.9,<3.14"
- Add Python 3.13 classifier, remove 3.8
- Build wheels for explicit Python versions (3.9, 3.10, 3.11, 3.12, 3.13)
- Remove --find-interpreter flag to prevent building for unsupported versions
- Update artifact names to include Python version
- Regenerate uv.lock with updated constraints

This prevents the CI error:
"the configured Python interpreter version (3.14) is newer than
PyO3's maximum supported version (3.13)"

Python 3.9-3.13 provides excellent coverage as:
- Python 3.9: EOL October 2025
- Python 3.10: EOL October 2026
- Python 3.11: Current stable
- Python 3.12: Latest stable
- Python 3.13: Newest release (Oct 2024)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add --interpreter flag to maturin builds to fix aarch64 cross-compilation
failure. Cross-compilation requires explicitly specifying the Python
interpreter since maturin can't auto-detect it for different architectures.

Changes:
- Linux: --interpreter python${{ matrix.python-version }}
- Windows: --interpreter python
- macOS: --interpreter python${{ matrix.python-version }}

This fixes the error:
"Couldn't find any python interpreters. Please specify at least one with -i"

The interpreter is provided by setup-python@v5, which installs the correct
Python version for each matrix combination.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Enable PyO3's abi3-py39 feature to build wheels using Python's stable ABI.
This allows a single wheel per platform to work across all Python versions
3.9-3.13, dramatically reducing build complexity and CI time.

Changes:
- Add "abi3-py39" feature to pyo3 dependencies
- Remove Python version matrix from wheel builds
- Build once per architecture with Python 3.9 (minimum version)
- Reduce from 25 builds to 5 builds (5x reduction):
  • 2 Linux (x86_64, aarch64)
  • 1 Windows (x64)
  • 2 macOS (x86_64, aarch64)

Benefits:
- 80% reduction in CI build time
- Simpler wheel naming (no Python version suffix)
- Same compatibility (Python 3.9-3.13+)
- Standard practice for PyO3 projects
- Forward compatible with future Python versions

Trade-off: Slight performance cost (~1-2%) from stable ABI, but negligible
for most use cases. The stable ABI restricts access to some Python internals
but we don't use any restricted APIs.

Wheel naming changes:
- Before: flagd_evaluator-0.1.0-cp39-cp39-manylinux_2_17_x86_64.whl
- After:  flagd_evaluator-0.1.0-py39-abi3-manylinux_2_17_x86_64.whl

The "abi3" tag indicates forward compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@aepfli aepfli merged commit 8d2baa3 into main Dec 26, 2025
19 checks passed
@aepfli

aepfli commented Dec 26, 2025

Copy link
Copy Markdown
Contributor Author

relates to #47

@aepfli aepfli mentioned this pull request Dec 26, 2025
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant